// web/src/lib/format.ts
import {formatDistanceToNow} from "date-fns";
// @ts-ignore
import zhCN from "date-fns/locale/zh-CN";

export const formatPrice = (price: number) => {
    // return new Intl.NumberFormat("en-US", {
    //     style: "currency",
    //     currency: "USD",
    // }).format(price);

    // 人民币format
    return new Intl.NumberFormat('zh-CN',
        {style: 'currency', currency: 'CNY'}
    ).format(price);
}

export const formatDateToNow = (date: Date) => {
    return formatDistanceToNow(date, {
        locale: zhCN
    })
}